package com.huawei.appgallery.forum.operation.report.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.util.ArrayList;
import java.util.List;
import o.bsv;
import o.bww.a;
import o.bww.d;
import o.bww.h;
import o.bxx;

public class ReportTypeAdapter extends BaseAdapter {
    private boolean isChecked;
    private List<bxx> list;
    private final Context mContext;
    private int[] reportTypeList = new int[]{h.ͺ, h.ˊॱ, h.ॱˋ, h.ᐝॱ, h.ॱᐝ, h.ॱˎ, h.ʻॱ, h.ˈ};

    static class c {
        public TextView ˋ;
        public RelativeLayout ˏ;
        public CheckBox ॱ;

        private c() {
        }
    }

    public ReportTypeAdapter(Context context) {
        this.mContext = context;
        initList();
    }

    private void initList() {
        this.list = new ArrayList();
        for (int i = 0; i < 8; i++) {
            this.list.add(new bxx());
        }
    }

    public int getCount() {
        if (this.reportTypeList == null || this.reportTypeList.length == 0) {
            return 0;
        }
        return this.reportTypeList.length;
    }

    public Object getItem(int i) {
        if (this.reportTypeList == null || this.reportTypeList.length == 0 || i >= this.reportTypeList.length) {
            return null;
        }
        return Integer.valueOf(this.reportTypeList[i]);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        c cVar;
        int i2 = 0;
        if (view == null || !(view.getTag() instanceof c)) {
            cVar = new c();
            view = LayoutInflater.from(this.mContext).inflate(a.ˏ, null);
            cVar.ˏ = (RelativeLayout) view.findViewById(d.ˋ);
            cVar.ˋ = (TextView) view.findViewById(d.ˏॱ);
            cVar.ॱ = (CheckBox) view.findViewById(d.ˋॱ);
            view.setTag(cVar);
        } else {
            cVar = (c) view.getTag();
        }
        final bxx o_bxx = (bxx) this.list.get(i);
        if (o_bxx != null) {
            cVar.ˏ.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ ReportTypeAdapter ˎ;

                public void onClick(View view) {
                    this.ˎ.isChecked = cVar.ॱ.isChecked();
                    cVar.ॱ.setChecked(!this.ˎ.isChecked);
                }
            });
            Object item = getItem(i);
            TextView textView = cVar.ˋ;
            if (item != null) {
                i2 = bsv.ॱ(String.valueOf(item), 0);
            }
            textView.setText(i2);
            cVar.ॱ.setOnCheckedChangeListener(new OnCheckedChangeListener(this) {
                final /* synthetic */ ReportTypeAdapter ˎ;

                public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                    o_bxx.ˎ(z);
                }
            });
        }
        return view;
    }

    public String getCheckedReport() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < getCount(); i++) {
            if (((bxx) this.list.get(i)).ˏ()) {
                stringBuilder.append(i + 1).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
            }
        }
        if (stringBuilder.length() > 0) {
            stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        }
        return stringBuilder.toString();
    }
}
